package Servlets;

import PackDatos.GestionBD;
import java.io.IOException;
import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.PreparedStatement;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class srv_eliminarDocente extends HttpServlet {

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {

        Connection cn = null;
        try {
            // conectamos la BD 
            GestionBD og = new GestionBD();
            cn = og.conectar();
            // Datos
            String pro_codigo = request.getParameter("codigo");
            //Actualizamos tabla Docente
            String query = "update profesor set pro_estado='0' where pro_codigo=?";
            PreparedStatement pstm = cn.prepareStatement(query);
            pstm.setString(1,pro_codigo);
            pstm.executeUpdate();
            cn.close();
            request.setAttribute("mensaje", "Docente Eliminado");
        } catch (Exception e) {
            request.setAttribute("mensaje", e.getMessage());
        }
        RequestDispatcher rd = request.getRequestDispatcher("srv_listarDocente");
        rd.forward(request, response);
    }
}